#ifndef __PUBLIC_H__
#define __PUBLIC_H__

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <poll.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>


#define RING_SIZE       2048
#define AF_MTU          2048

#define AF_VLAN_ENABLE  1
#define MAX_NUM         1024
#define VLAN_TAG_LEN    4

#define AF_FAILED       -1
#define AF_SUCCEED      0

#define DEFAULT_ORDER   3
#define INFTIM          -1

#define NET_TYPE_ARP    0x0608
#define NET_TYPE_IP     0x0008
#define NET_VLAN_TAG    0x0081


#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(1)

    typedef struct _afpacket
    {
        u_int8_t    *buf;
        u_int8_t    *p_ethhdr;
        u_int8_t    *p_iphdr;
        u_int8_t    *p_tranhdr;
        u_int8_t    *p_payhdr;

        u_int32_t   len;
        u_int16_t   iph_len;
        u_int16_t   trh_len;
        u_int16_t   pay_len;
        u_int8_t    vlan_len;
    }afpacket;

    typedef struct _yx_pkt
    {
        afpacket    *rx;
        afpacket    *tx;
    }yx_pkt;
#pragma pack()
#ifdef __cplusplus
}
#endif

#endif
